package com.shjn.squirrel.fragment;

import android.graphics.Bitmap;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;

import com.google.gson.Gson;
import com.shjn.squirrel.R;
import com.shjn.squirrel.application.MyApplication;
import com.shjn.squirrel.bean.httpBean.DeviceIdReq;
import com.shjn.squirrel.bean.httpBean.RespCommonResult;
import com.shjn.squirrel.customView.BackAndTimerView;
import com.shjn.squirrel.model.Constant;
import com.shjn.squirrel.model.LocalStorage;
import com.shjn.squirrel.model.RecyclerInfoCache;
import com.shjn.squirrel.utils.Base64Utils;
import com.shjn.squirrel.utils.OkhttpHelper;

import java.io.IOException;

import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Response;

/**
 * 回收员扫码登录
 */
public class RecyclerScanFragment extends BaseFragment implements View.OnClickListener {

    private static RecyclerScanFragment instance;
    private Button mSwitchLogin;
    private ImageView mRecyclerQRcode;

    public RecyclerScanFragment() {
    }

    public synchronized static RecyclerScanFragment getInstance() {
        if (instance == null) {
            instance = new RecyclerScanFragment();
        }
        return instance;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return createView(inflater, R.layout.recycler_scan_login, container);
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        initTimer();
        initView();
    }

    /**
     * 初始化倒计时器
     */
    private void initTimer() {
        //加载定时器面板，设置定时时间
        mActivity.mBackAndTimer.setOnBackListener(new BackAndTimerView.OnBackListener() {
            @Override
            public void onBack() {
                //返回首页
                if (!UserSelectFragment.getInstance().isAdded()) {
                    mActivity.mBackAndTimer.setVisibleState(false);
                    mActivity.getFragmentManager().beginTransaction()
                            .replace(R.id.mid, UserSelectFragment.getInstance())
                            .commit();
                    TopFragment.getInstance().mBtnMyRecycler.setVisibility(View.VISIBLE);
                }
            }
        }).setBackVisibleState(true).setOnTimerFinishListener(new BackAndTimerView.OnTimerFinishListener() {
            @Override
            public void onTimerFinish() {
                //返回到首页
                if (!UserSelectFragment.getInstance().isAdded()) {
                    mActivity.mBackAndTimer.setVisibleState(false);
                    mActivity.getFragmentManager().beginTransaction()
                            .replace(R.id.mid, UserSelectFragment.getInstance())
                            .commit();
                    TopFragment.getInstance().mBtnMyRecycler.setVisibility(View.VISIBLE);
                }
            }
        }).setTime(60).setVisibleState(true).start();
    }

    /**
     * 初始化相关控件
     */
    private void initView() {
        //切换至手机号登录按钮,绑定点击事件
        mSwitchLogin = (Button) mView.findViewById(R.id.btn_recycler_psw_login);
        mSwitchLogin.setOnClickListener(this);

        //获取二维码
        mRecyclerQRcode = (ImageView) mView.findViewById(R.id.img_recycler_login_qr_code);
        //------测试使用-----//
        String base64Imag = "iVBORw0KGgoAAAANSUhEUgAAAQQAAAEECAYAAADOCEoKAAAapklEQVR4Xu2d63pbuQ5DJ+//0Dmfe9rm0sRr7S2YlmPMX4kECJKI7Kadl9fX19f/+l8VqAJV4L///nupIXQOqkAV+KNADaGzUAWqwF8FaggdhipQBWoInYEqUAX+VaAvhE5FFagCfSF0BqpAFegLoTNQBarAFQXwI8PLy8vTCLj6KxlGq1WMSzMIhzAo/oJBOWgoEhgmB/GgOhIYxGGXc9Li12zR7yFUMN9Oo5VpCiESDmFQfA2BOvCY5zQXNYRPfTWCXRuFiUXrC+HYMlJPTc+OIe57m7SoIdQQvp1eMzy3NsfEslIdCYx9LeAjM9KihlBDqCH0O7IPM9DvEN7JYRz01j8VzU8b+qlGdVB8v0MwXXi8OzQXfSH0hdAXQl8IfSF8twXGQftCcD8ZE68Qk4PYUE8TGMRhl3PSIvJCMCA7CGIaT7VQDoo3OhCGyUE8EhiGB90hnhSfODda7MDT1Eq1mDqWv0MwIKaYW98hscznZsqR0IIwjE7EI4FheNAd4knxiXOjxQ48Ta1Ui6mjhvBOaRIsITg1ljAoPmFsBiNxh/ROYFAOo/cOPKmOX899+D7E1FFDqCGYWbvJHTOgNwF+l5SWyB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xJaEMaFJ+FQDoq/YERyvAJSBOTlxfRu6Q4JRnWYphFBg0E5Js5JqwkOUxjUk4QWhGFmi3IYnpEcNYS30TSiXxtkasjUEhDOap2Uf6dz6klCC8KoIXyaCCPY6hBRYw0HykEcDQblmDhfrXOCYwqDepLQgjBqCDWE1DzfJE9iCW5C7AZJaVkTWhBGDaGGcIPRzqVMLEGOzW0z0bImtCCMGkIN4bZTvpg9sQSLFMbCaVkTWhBGDaGGMDbwZ4ASS3AG9x4xtKwJLQijhnCPzgPmRNNM2VMDeI2L4WD0MvWu8iCMVZ5TWhica7WaOlcxLvgjv5hETZ04TwhqclAtkaYt/l6H4ZCotVq8KWA0ryHQxATPzYBT00wOokwYFP/LxWsIf2V6FC1W+27qXMXoC+HT9pGgpim00IRB8TWEjwqt9sT0YxXDfIdAfTccTC2IM/GbikRi4jwhqMlBtUSa1hdCXwhfDFpktmoI/nNeDYHs7th5ZIAfxBxXazWzt4rRjwz9yPDtBpsBPLb+/96ODHAN4a+wET37QugL4avFriG8qZLQYnVZDYdVjL4Q+kLoC+H1FR86ZhkpyeqyGg6rGBFDICEe6ZwEpaZQfEoL4kE4UzyJB52v1mm+3TcYpFciR0IL4kkYNYTwCyHRENW0gc/Nhset75hFIw7UE4MxkYPqSPAkjBpCDcHMyN3umCUgchPLbHgSD6pjAqOGUEOgObzruVkCIkiLaDAmclAdCZ6EUUOoIZgZudsdswREbmKZDU/iQXVMYNQQagg0h3c9N0tABGkRDcZEDqojwZMwagg1BDMjd7tjloDITSyz4Uk8qI4JjBpCDYHm8K7nZgmIIC2iwZjIQXUkeBKGMgSTpHeqQBX4GQrgP5DyM8psFVWgChgFaghGpd6pAk+iQA3hSRrdMquAUaCGYFTqnSrwJArUEJ6k0S2zChgFaghGpd6pAk+iQA3hSRrdMquAUaCGYFTqnSrwJAr8D4mb8mxfk+9HAAAAAElFTkSuQmCC";
        Bitmap bitmap = Base64Utils.base64ToBitmap(base64Imag);
        //设置二维码
        mRecyclerQRcode.setImageBitmap(bitmap);
//        OkhttpHelper.postRequest(Constant.baseUrl + "machine/QRCode/recycler",
//                new Gson().toJson(new DeviceIdReq(LocalStorage.getDeviceID(MyApplication.getInstance()))),
//                new Callback() {
//                    @Override
//                    public void onFailure(Call call, IOException e) {
//                        Log.i("info", "recyclerQRcode_onFailure: " + e.getMessage());
//                    }
//
//                    @Override
//                    public void onResponse(Call call, Response response) throws IOException {
//                        RespCommonResult result = new Gson().fromJson(response.body().string(), RespCommonResult.class);
//                        if (result.getStateCode() == 1) {
//                            String base64Imag = (String) result.getResult().get("base64Img");
//                            final Bitmap bitmap = Base64Utils.base64ToBitmap(base64Imag);
//                            mActivity.runOnUiThread(new Runnable() {
//                                @Override
//                                public void run() {
//                                    if (RecyclerScanFragment.getInstance().isAdded()) {
//                                        //设置二维码
//                                        mRecyclerQRcode.setImageBitmap(bitmap);
//                                        //轮询服务器是否有回收员扫描了二维码
//                                        OkhttpHelper.postRequest(Constant.baseUrl + "machine/verification/getScanRecycler",
//                                                new Gson().toJson(new DeviceIdReq(LocalStorage.getDeviceID(MyApplication.getInstance()))),
//                                                new Callback() {
//                                                    @Override
//                                                    public void onFailure(Call call, IOException e) {
//                                                        Log.i("info", "recyclerScanCheck_onFailure: " + e.getMessage());
//                                                    }
//
//                                                    @Override
//                                                    public void onResponse(Call call, Response response) throws IOException {
//                                                        final RespCommonResult result = new Gson().fromJson(response.body().string(), RespCommonResult.class);
//                                                        if (result.getStateCode() == 1) {
//                                                            mActivity.runOnUiThread(new Runnable() {
//                                                                @Override
//                                                                public void run() {
//                                                                    if (RecyclerScanFragment.getInstance().isAdded()) {
//                                                                        mActivity.mBackAndTimer.stop();
//                                                                        RecyclerInfoCache.loginState = true;
//                                                                        RecyclerInfoCache.telNum = (String) result.getResult().get("account");
//                                                                        //跳转到垃圾选择页面
////                                                                        getActivity().getFragmentManager().beginTransaction()
////                                                                                .replace(R.id.mid, RecyclerSelectFragment.getInstance())
////                                                                                .commit();
//
//                                                                    }
//                                                                }
//                                                            });
//                                                        } else {
//                                                            if (RecyclerScanFragment.getInstance().isAdded()) {
//                                                                //轮询
//                                                                OkhttpHelper.requestAgain(call, this);
//                                                                Log.i("info", "recyclerScanCheck again!");
//                                                            }
//                                                        }
//                                                    }
//                                                });
//                                    }
//                                }
//                            });
//                        }
//
//                    }
//                });
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.btn_recycler_psw_login:
                if (!RecyclerTeleFragment.getInstance().isAdded()) {
                    //暂停倒计时器
                    mActivity.mBackAndTimer.stop();
                    //跳转到回收员手机号登录页面
                    mActivity.getFragmentManager().beginTransaction()
                            .replace(R.id.mid, RecyclerTeleFragment.getInstance())
                            .commit();
                }
                break;
            default:
                break;
        }
    }
}
